--TEST--
string MySQLndUhConnection::getServerStatistics(resource $connection)
--SKIPIF--
<?php require_once('skipif.inc'); ?>
--FILE--
<?php
	require_once('config.inc');

	class proxy extends MySQLndUhConnection {
		public function getServerStatistics($res) {
			printf("%s(%s)\n", __METHOD__, var_export(func_get_args(), true));
			return parent::getServerStatistics($res);
		}
	}

	class proxy2 extends MySQLndUhConnection {
		public function getServerStatistics($res) {
			printf("%s(%s)\n", __METHOD__, var_export(func_get_args(), true));
			$stats = "my statistics are nice, aren't they?";
			return $stats;
		}
	}

	class proxy3 extends MySQLndUhConnection {
		public function getServerStatistics($res) {
			printf("%s(%s)\n", __METHOD__, var_export(func_get_args(), true));
		}
	}

	class proxy4 extends MySQLndUhConnection {
		public function getServerStatistics($res) {
			return -1;
		}
	}

	class proxy5 extends MySQLndUhConnection {
		public function getServerStatistics($res) {
			return str_repeat('a', 4096);
		}
	}


	$conn = mysqlnd_uh_test\connect::mysqli();
	$stats = $conn->stat();
	printf("stats: %s/%s\n", gettype($stats), (strlen($stats) > 20) ? 'reasonable' : 'too small');
	mysqlnd_uh_test\query_test::mysqli($conn);

	mysqlnd_uh_set_connection_proxy(new proxy());
	$stats = $conn->stat();
	var_dump($stats);
	printf("stats: %s/%s\n", gettype($stats), (strlen($stats) > 20) ? 'reasonable' : 'too small');
	mysqlnd_uh_test\query_test::mysqli($conn);

	mysqlnd_uh_set_connection_proxy(new proxy2());
	$stats = $conn->stat();
	var_dump($stats);

	mysqlnd_uh_set_connection_proxy(new proxy3());
	$stats = $conn->stat();
	var_dump($stats);
	mysqlnd_uh_test\query_test::mysqli($conn);

	mysqlnd_uh_set_connection_proxy(new proxy4());
	var_dump($stats = $conn->stat());

	mysqlnd_uh_set_connection_proxy(new proxy5());
	var_dump($stats = $conn->stat());

	print "done!";
?>
--EXPECTF--
stats: string/reasonable
proxy::getServerStatistics(array (
  0 => NULL,
))
string(%d) "%s"
stats: string/reasonable
proxy2::getServerStatistics(array (
  0 => NULL,
))
string(36) "my statistics are nice, aren't they?"
proxy3::getServerStatistics(array (
  0 => NULL,
))

Warning: mysqli::stat(): (MySQLnd User Handler) The method MySQLndUhConnection::getServerStatistics() did not return a string value as it should in %s on line %d
bool(false)

Warning: mysqli::stat(): (MySQLnd User Handler) The method MySQLndUhConnection::getServerStatistics() did not return a string value as it should in %s on line %d
bool(false)
string(4096) "%s"
done!